home *** CD-ROM | disk | FTP | other *** search
- name execbeep
-
- dp equ dword ptr
- of equ offset
-
- code segment
- assume cs:code, ds:code
- org 100h
-
- begin: jmp start
-
- beep proc ; beep the speaker
- push ax ; save
- push cx
- in al,97 ; get port values
- and al,0feh ; turn speaker on
- out 97,al
- mov cx,bx ; cycles to cx
- more_sound: push cx ; save cycles
- xor al,2 ; flip push/pull
- out 97,al
- mov cx,dx ; wait
- part1: loop part1
- xor al,2 ; flip push/pull
- out 97,al
- mov cx,dx ; wait
- part2: loop part2
- pop cx
- loop more_sound
- pop cx ; restore
- pop ax
- ret
- beep endp
-
- beep_low proc
- push bx
- push dx
- mov bx,50 ; number of cycles
- mov dx,100 ; half cycle time
- call beep
- pop dx
- pop bx
- ret
- beep_low endp
-
- beep_high proc
- push bx
- push dx
- mov bx,100 ; number of cycles
- mov dx,50 ; half cycle time
- call beep
- pop dx
- pop bx
- ret
- beep_high endp
-
- old_int21 dw 2 dup(?); former int 21h address
-
- new_int21 proc far
- cmp ah,4bh ; EXEC function?
- je exec_beep ; yes, beep, then call EXEC
- cmp ah,4dh ; request to get return code?
- je retc_beep ; yes, beep then get return code
- jmp dp cs:old_int21 ; no, pass it on
-
- exec_beep: call beep_low ; beep before EXEC
- jmp dp cs:old_int21 ; go do EXEC
-
- retc_beep: call beep_high ; beep after EXEC
- jmp dp cs:old_int21 ; go get return code
- new_int21 endp
-
- start: mov ax,3521h ; get int 21h
- int 21h
- mov old_int21,bx ; store offset
- mov old_int21+2,es ; store segment
- mov dx,of new_int21 ; ds:dx -> new int 21h
- mov ax,2521h
- int 21h
- mov dx,of start ; discard excess
- add dx,0fh
- shr dx,1
- shr dx,1
- shr dx,1
- shr dx,1
- mov ax,3100h ; keep process
- int 21h
-
- code ends
- end begin